import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EmployeeInfoVO, EmployeeInfoForm, EmployeeInfoQuery } from '@/api/busi/employeeInfo/types';
import {UnitInfoVO} from "@/api/busi/unitInfo/types";

/**
 * 查询员工信息列表
 * @param query
 * @returns {*}
 */

export const listEmployeeInfo = (query?: EmployeeInfoQuery): AxiosPromise<EmployeeInfoVO[]> => {
  return request({
    url: '/busi/employeeInfo/list',
    method: 'get',
    params: query
  });
};

export const employeeListByUnitId = (id: string | number): AxiosPromise<EmployeeInfoVO[]> => {
  return request({
    url: '/busi/employeeInfo/list/' + id,
    method: 'get'
  });
};

/**
 * 查询员工信息详细
 * @param id
 */
export const getEmployeeInfo = (id: string | number): AxiosPromise<EmployeeInfoVO> => {
  return request({
    url: '/busi/employeeInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增员工信息
 * @param data
 */
export const addEmployeeInfo = (data: EmployeeInfoForm) => {
  return request({
    url: '/busi/employeeInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改员工信息
 * @param data
 */
export const updateEmployeeInfo = (data: EmployeeInfoForm) => {
  return request({
    url: '/busi/employeeInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除员工信息
 * @param id
 */
export const delEmployeeInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/busi/employeeInfo/' + id,
    method: 'delete'
  });
};

/**
 * 获取识别后的单位信息
 * @param imageId 上传的图片id
 */
export const getEmployeeIdCard = (imageId?: string | number): AxiosPromise<EmployeeInfoVO> => {
  return request({
    url: '/busi/employeeInfo/getIdCard/' + imageId,
    method: 'get'
  });
};
